var windowName = "shopInsurePay";
var Page,count = 0,list;
apiready = function(){
    onWindowShow(function () {
        getData()
    })
    onWindowHide(function () {
    })
    Page = createVM("#Page",{
        curTab:0
        ,pay:2000
        ,money:[]
        ,payType:100
    },{
        //页面方法
        "init":function () {
            var money = getLocData("shopInsurePay");
            if (isTrue(money)) {
                Page.money = money
            }

            // getData()
        }
        ,setCur:function (index) {
            this.curTab = index
            log(index)
        }
        ,startPay:function () {
            apiGet("/app/pay/insuer",{payType:this.payType,money:this.pay},function (res,code) {
                if (code == 200) {
                    if (Page.payType == 100){
                        //微信支付
                        wxPay(res.data,function (ret) {
                            logJson(ret,"PAY_RET")
                        })
                    }
                    if (Page.payType == 200) {
                        //支付宝支付
                        aliPay(res.data,function (ret,err) {
                            logJson(ret,"ali_ret")
                            logJson(err,"ali_err")
                        });
                    }
                    // aliPay(res.data,function (ret,err) {
                    //     logJson(ret,"ali_ret")
                    //     logJson(err,"ali_err")
                    // })
                }
            })
        }
    })
    Page.init()
}

function getData() {
    apiGet("/app/config",{},function (res,code) {
        if (code == 200) {

            setLocData("shopInsurePay",res.data.moneySet)
            Page.money = res.data.moneySet;
        }
        logJson(res,"shopInsurePay");
    })

}